import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class MyInsertMain {

	public static void main(String[] args) throws ClassNotFoundException,
			SQLException {

		String url = "jdbc:hsqldb:file:mytest";
		Class.forName("org.hsqldb.jdbcDriver");
		Connection connection = DriverManager.getConnection(url);

		Integer[] ids = new Integer[] { 1, 2, 3, 4, 5 };
		String[] names = new String[] { "Tom", "Greg", "Mark", "John", "Frank" };

		for (int i = 0; i < names.length; i++) {

			Integer id = ids[i];
			String name = names[i];

			User user = new User(id, name);

			Statement statement = connection.createStatement();

			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.append("INSERT INTO USER VALUES(");
			stringBuilder.append(user.getId() + ",");
			stringBuilder.append("'" + user.getName() + "'");
			stringBuilder.append(" )");
			String statementString = stringBuilder.toString();

			statement.execute(statementString);

			statement.close();
		}

		connection.close();
	}
}
